package gsw.tool.pluggable.pm;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.support.annotation.Nullable;

/**
 * 自定义PMS的远程服务，运行在单独的进程，与宿主隔离，更安全。
 */
public class MPackageManagerService extends Service {
    //自定义的PMS
    private static MPackageManager PMS;

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return getPackageManagerService(this);
    }

    public MPackageManager getPackageManagerService(Context context) {
        if (PMS == null) {
            synchronized (MPackageManagerService.class) {
                if (PMS == null) {
                    PMS = new MPackageManager(this);
                }
            }
        }
        return PMS;
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }
}
